﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.MachineSys.JSDWF
{
    public partial class MyDWFApplyDetailList : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看, Permission.修改, Permission.新增, Permission.删除 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "MyDWFApplyList";
            }
        }

        #region 属性 (查询条件)


        protected Guid ApplyGUID
        {
            get
            {
               string r=  GetRequestValue<string>("ApplyGUID", "");
               return new Guid(r);
            }
        }
        #endregion
        protected void Page_Load(object sender, EventArgs e)
        {
            this.rpMenu.DataSource = JSDWFApplyController.GetDetailByApplyGUID(ApplyGUID);
            this.rpMenu.DataBind();
        }

        /// <summary>
        /// 获取相应的图纸，当前用户的操作权限
        /// 要么可以查看，要么只能先申请
        /// </summary>
        /// <param name="DWFID"></param>
        /// <returns></returns>
        protected string GetListItemRight(object _DWFID, object FileName)
        {
            Guid DWFID = new Guid(_DWFID.ToString());
            //是否在申请判
            List<JSDWFApplyDetailInfo> applydetailList = JSDWFApplyController.GetDWFApplyByUserName(base.User.UserName);
            if (applydetailList != null)
            {
                JSDWFApplyDetailInfo obj = applydetailList.Find(e => e.DWFID == DWFID);
                if (obj != null)
                    return string.Format( "<b style='color:Lime;'>{0}</b>",FileName);
            }
            //权限判断
            List<JSUserDWFInfo> userDwfList = JSUserDWFController.GetListByUserName(base.User.UserName);
            if (userDwfList != null)
            {
                JSUserDWFInfo rightObj = userDwfList.Find(e => e.DWFID == DWFID);
                if (rightObj == null)
                {
                    //没权限
                    return string.Format("{0}", FileName);
                }
                else
                {
                    return string.Format("<a  title=\"点击可查看图纸\" href=\"JSDWF/JSDWFView.aspx?DWFID={0}\" target=\"ajax\" rel=\"MyDWFApplyListDetailViewJbox\" style=\"color:Green\" >{1}</a>", DWFID, FileName);
                }
            }
            else
            {
                return string.Format("{0}", FileName);
            }

        }
    }
}